home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / maximus / mul100.zip / REGUSER.ZIP / REGUSER.SCR < prev    next >
Text File  |  1992-12-28  |  4KB  |  167 lines

  1. // REGUSER.SCR   Christmas Day 1992
  2. //
  3. // Utility to allow On-Line registration of callers by John Daniels
  4. //                                                     3:690/688@FidoNet
  5. // Uses LASTUSER.BBS or LASTUS??.BBS (on multi nodes systems)
  6. //
  7. // Command line paramaters are:
  8. //                              1)  Task Number (returned by Maximus
  9. //                                               %K)
  10. //                              2)  Number of days/months membership
  11. //                                  any number less than 6 will register a
  12. //                                  caller for 7 days!
  13. //
  14. // Needs to be called via Mecca Xtern_Erlvl command
  15. //                                        eg [Xtern_Erlvl]156 %K 6
  16. //                                           will exit with errorlevel 156
  17. //                                           task No. and 6 months' membership
  18. //
  19. // Upon re-start (Max -r) Maximus reads LASTUS??.BBS and updates its in
  20. // memory data the current caller.
  21. // 
  22. char *ufile = "LASTUSER.BBS";              
  23. char *task = "00";
  24. char date[8], *p, *q, buff[8], *expdate, *yr, *mt, *dy, *buf;
  25.  
  26. int newdate, advance, thedate, xtend, retval;
  27. int day, mont, year, ed, mn, ok, month;
  28. int ml[12];
  29. int j[12];
  30.  
  31. long jn, nd, yy, jul;
  32. long a, b;
  33.  
  34. main (int argc, char *arg1, char *arg2)          // Main program
  35. {
  36.     j[1]=0; j[2]=31; j[3]=28; j[4]=31; j[5]=30; j[6]=31;
  37.     j[7]=30; j[8]=31; j[9]=31; j[10]=30; j[11]=31; j[12]=30;
  38.  
  39.     ml[1]=31; ml[2]=28; ml[3]=31; ml[4]=30; ml[5]=31; ml[6]=30; 
  40.     ml[7]=31; ml[8]=31; ml[9]=30; ml[10]=31; ml[11]=30; ml[12]=31;
  41.  
  42.  
  43.     if (argc) strcpy(task,arg1);
  44.     printf ("\n\nTask Number %s\n",task);
  45.     strcpy(ufile,"LASTUS");
  46.     strcat(ufile,task);
  47.     strcat(ufile,".BBS");
  48.     retval = strcmp(ufile,"LASTUS00.BBS");
  49.     if (retval==0) { 
  50.        strcpy(ufile,"LASTUSER.BBS");
  51.        }
  52.     printf("Reading:    %s\n",ufile);
  53.     expdate = "";
  54.     if (argc) xtend=atoi(arg2);
  55.     if (xtend < 2) {
  56.        retval = discdate();
  57.        jul = julian(day,month,year);
  58.        retval = revjul(jul+7);
  59.        itoa(day,buf,10);
  60.        if (day < 10) {
  61.        expdate = strcat(expdate,"0");
  62.        expdate = strcat(expdate,buf);
  63.        }
  64.        else
  65.        {
  66.        expdate = strcat(expdate,buf);
  67.        }
  68.        expdate = strcat(expdate,"-");
  69.        itoa(mont,buf,10);
  70.        if (mont < 10) {
  71.        expdate = strcat(expdate,"0");
  72.        expdate = strcat(expdate,buf);
  73.        }
  74.        else
  75.        {
  76.        expdate = strcat(expdate,buf);
  77.        }
  78.        expdate = strcat(expdate,"-");
  79.        itoa(year-1900,buf,10);
  80.        expdate = strcat(expdate,buf);
  81.        printf("\nSeven Days FREE Membership...\n");
  82.        }
  83.     else
  84.        {
  85.        thedate = SysDate();
  86.        newdate = GenDate(thedate,xtend);
  87.        expdate = DateToStr(newdate);
  88.        printf("\nSix Months Membership...\n");
  89.        }
  90.     printf ("New Expiry Date is %s\n\n",expdate);
  91.     newdate = StrToDate(expdate);
  92.  
  93.     if (!BaseOpen (ufile)) {
  94.     printf ("ERROR opening user file %s\n",ufile);
  95.     exit ();
  96.     }
  97.  
  98.     if (BaseRead (1)) {
  99.     USRxpdate = newdate;
  100.     USRpriv = PRIVIL;
  101.     USRxpflag = XP_DATE_DEMOTE;
  102.     USRxppriv = DISGRACE;
  103.     BaseWrite (1);
  104.     BaseClose ();
  105.     exit();
  106.     }
  107. }
  108.  
  109. discdate ()
  110. {
  111.     newdate=SysDate();
  112.     buff=DateToStr(newdate);
  113.     strcpy(date,buff); strcpy(p,date);
  114.     day=atoi(p);
  115.     strcpy(date,buff); strcpy(p,date);
  116.     p++;p++;p++;
  117.     month=atoi(p);
  118.     strcpy(date,buff); strcpy(p,date);
  119.     p++;p++;p++;p++;p++;p++;
  120.     year=atoi(p)+1900;
  121.     return 1;
  122. }
  123.  
  124. revjul (long jj)
  125. {
  126.     ok = 0;
  127.     nd = (jj*100); year = (nd/36525); 
  128.     yy = (year * 36525); day = (nd - yy)/100;
  129.     if (day == 0) {
  130.         day = 31; mont = 12; year = year -1;
  131.         return 1;
  132.         }
  133.     yy = (year * 100);
  134.     if ( ((year*100) / 4) > ((year /4) * 100) ) {
  135.         ml[2] = 28;
  136.         }
  137.     else {
  138.         ml[2] = 29;
  139.         }
  140.     for (mn=1; day > (ml[mn])+1; mn++) {
  141.         day = day - ml[mn];
  142.         }
  143.     mont = mn;
  144. return 1;
  145. }
  146.  
  147. julian (int d, int m, int y)
  148. {
  149.     yy = (y*100); nd = (yy*365); yy = (y/4)*100; nd = nd+yy;
  150.     nd = (nd/100);
  151.     ed = ( ((y*100)/4) - ((y/4)*100));
  152.     if (ed > 0) {
  153.        ed = 1;
  154.        j[3]=28;
  155.        }
  156.     else {
  157.        ed = 0;
  158.        j[3]=29;
  159.        }
  160.     jn = 0;
  161.     for (mn=1; mn<m+1; mn++) {
  162.         jn = jn + j[mn];
  163.         }
  164.     jn = jn + d + nd + ed;
  165.     return jn;
  166. }
  167.